<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        function Person(name,age) {
            //创建实例的属性
            this.name = name
            this.age = age

        }

        Person.prototype.eat = function(){
            console.log("每日干饭");
        }

        Person.run = function (){
            console.log("跑不动了呀");
        }

        function Student(name,age,height){
            //让student实例化对象指向Person的this
            Person.call(this,name,age)
            this.height = height
        }

        Student.prototype.appropriate = function(){
            console.log("欣赏风景");
        }

        //原型继承
        Student.prototype = new Person
        //修正constructor的指向
        Student.prototype.constructor = Student

        const stu = new Student("张三","18","170")
        console.log(stu);
    </script>
</body>
</html>

